home *** CD-ROM | disk | FTP | other *** search
/ PD ROM 1 / PD ROM Volume I - Macintosh Software from BMUG (1988).iso / Stacks / Updates⁄New / TEXAS for BMUG / C progs / TEXAS XFCNs ƒ / mergeIndicesXFCN ƒ / del_ren_files.z1.c < prev    next >
Encoding:
C/C++ Source or Header  |  1987-12-31  |  3.3 KB  |  113 lines  |  [TEXT/KAHL]

  1. /* routines to delete and/or rename files ... 871203-... ^z
  2.  * part of the mergeIndices project.... mods 871230 by ^z for XFCN...
  3.  */
  4.  
  5. #include "mergeIndices.z.h"
  6.  
  7. extern Str255 fn[3][3];
  8. extern int vRef[3][3], refNum[3][3];
  9. extern long first_text_file_size;
  10.  
  11. /* delete the now-unneeded key and pointer files so that there will
  12.  * be more room on disk ...(or give the user the option to keep them
  13.  * if so desired?? -- maybe someday!) .... keep going after an error,
  14.  * but give some warnings to the user....
  15.  */
  16.  
  17. int delete_old_key_and_ptr_files ()
  18.   {
  19.     give_msg ("\pDeleting old key & ptr dataspace files...");
  20.     if (FSClose (refNum[MERGEDOUT][KEYFILE]) != noErr)
  21.       {
  22.         give_msg ("\pError closing merged key file! -- click mouse to continue...");
  23.         beepWait ();
  24.       }
  25.     refNum[MERGEDOUT][KEYFILE] = 0;
  26.     if (FSClose (refNum[MERGEDOUT][PTRFILE]) != noErr)
  27.       {
  28.         give_msg ("\pError closing merged ptr file! -- click mouse to continue...");
  29.         beepWait ();
  30.       }
  31.     refNum[MERGEDOUT][PTRFILE] = 0;
  32.     if (FSClose (refNum[FIRSTIN][KEYFILE]) != noErr)
  33.       {
  34.         give_msg ("\pError closing first key file! -- click mouse to continue...");
  35.         beepWait ();
  36.       }
  37.     refNum[FIRSTIN][KEYFILE] = 0;
  38.     if (FSDelete (fn[FIRSTIN][KEYFILE], vRef[FIRSTIN][KEYFILE]) != noErr)
  39.       {
  40.         give_msg ("\pError deleting first key file! -- click mouse to continue...");
  41.         beepWait ();
  42.       }
  43.     if (FSClose (refNum[FIRSTIN][PTRFILE]) != noErr)
  44.       {
  45.         give_msg ("\pError closing first ptr file! -- click mouse to continue...");
  46.         beepWait ();
  47.       }
  48.     refNum[FIRSTIN][PTRFILE] = 0;
  49.     if (FSDelete (fn[FIRSTIN][PTRFILE], vRef[FIRSTIN][PTRFILE]) != noErr)
  50.       {
  51.         give_msg ("\pError deleting first ptr file! -- click mouse to continue...");
  52.         beepWait ();
  53.       }
  54.     if (FSClose (refNum[SECONDIN][KEYFILE]) != noErr)
  55.       {
  56.         give_msg ("\pError closing second key file! -- click mouse to continue...");
  57.         beepWait ();
  58.       }
  59.     refNum[SECONDIN][KEYFILE] = 0;
  60.     if (FSDelete (fn[SECONDIN][KEYFILE], vRef[SECONDIN][KEYFILE]) != noErr)
  61.       {
  62.         give_msg ("\pError deleting second key file! -- click mouse to continue...");
  63.         beepWait ();
  64.       }
  65.     if (FSClose (refNum[SECONDIN][PTRFILE]) != noErr)
  66.       {
  67.         give_msg ("\pError closing second ptr file! -- click mouse to continue...");
  68.         beepWait ();
  69.       }
  70.     refNum[SECONDIN][PTRFILE] = 0;
  71.     if (FSDelete (fn[SECONDIN][PTRFILE], vRef[SECONDIN][PTRFILE]) != noErr)
  72.       {
  73.         give_msg ("\pError deleting second ptr file! -- click mouse to continue...");
  74.         beepWait ();
  75.       }
  76.     
  77.     return (1);
  78.   }
  79.  
  80.  
  81. int delete_and_rename_text_files ()
  82.   {
  83.     give_msg ("\pDeleting and renaming text dataspace files...");
  84.     if (FSClose (refNum[SECONDIN][TEXTFILE]) != noErr)
  85.       {
  86.         give_msg ("\pError closing second text file! -- click mouse to continue...");
  87.         beepWait ();
  88.       }
  89.     refNum[SECONDIN][TEXTFILE] = 0;
  90.     if (FSDelete (fn[SECONDIN][TEXTFILE], vRef[SECONDIN][TEXTFILE])
  91.             != noErr)
  92.       {
  93.         give_msg ("\pError deleting second text file! -- click mouse to continue...");
  94.         beepWait ();
  95.       }
  96.     if (FSClose (refNum[FIRSTIN][TEXTFILE]) != noErr)
  97.       {
  98.         give_msg ("\pError closing merged text file! -- click mouse to continue...");
  99.         beepWait ();
  100.       }
  101.     refNum[FIRSTIN][TEXTFILE] = 0;
  102.     if (Rename (fn[FIRSTIN][TEXTFILE], vRef[FIRSTIN][TEXTFILE],
  103.                     fn[MERGEDOUT][TEXTFILE]) != noErr)
  104.       {
  105.         give_msg ("\pError renaming merged text file! -- click mouse to continue...");
  106.         beepWait ();
  107.       }
  108.  
  109.     return (1);
  110.   }
  111.  
  112.  
  113.